import os
import platform

from flask_sqlalchemy import SQLAlchemy

from app.env import UPLOAD_FOLDER,SQLALCHEMY_DATABASE_URI,SITE_URL,ALLOW_EXTENSIONS,SAVE_UPLOAD_FOLDER
from flask import Flask,jsonify

if platform.system() == "windows":
    slash = "\\"
else:
    platform.system() == "linux"
    slash = "/"

app = Flask(__name__)
app.config["UPLOAD_FOLDER"] = UPLOAD_FOLDER
# app.config.from_object(config.db.Config)
app.config['SQLALCHEMY_DATABASE_URI'] = SQLALCHEMY_DATABASE_URI
app.config['SQLALCHEMY_COMMIT_TEARDOWN'] = True
app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = True
app.config['SQLALCHEMY_COMMIT_ON_TEARDOWN'] = True
app.config['JSON_AS_ASCII'] = False  #返回json中文正常显示
app.jinja_env.auto_reload = True
app.config['TEMPLATES_AUTO_RELOAD'] = True
db = SQLAlchemy(app)

# 判断文件夹是否存在，如果不存在则创建
if not os.path.exists(UPLOAD_FOLDER):
    os.makedirs(UPLOAD_FOLDER)
else:
    pass

from app.controller import index,page,user